var topologyTree;
var topologyTreeMenu;

function initTree() {
	// tree onClick, onDblClick Check value
	var clickState = null;
	
	topologyLayout.attachHTMLString('<div id="treeDiv"></div>');
	topologyTree = new dhtmlXTreeObject('treeDiv', '100%', '100%', 0);

	topologyTree.setImagesPath(IMAGE_PATH + '/dhxtree_web/');
//	topologyTree.setSkin('dhx_web');
	topologyTree.enableHighlighting(true);

	topologyTree.attachEvent('onClick', function(id) {
		if ( clickState != null ) {
			window.clearTimeout(clickState);
		}
		
		clickState = window.setTimeout(function() {
			boardLayout.detachObject(true);
			setTitleAndCallBoard(id);
			setDataView(id);
		}, 500);
	});
	topologyTree.attachEvent('onRightClick', function(id, ev) {
		topologyTree.selectItem(id);
	});

	var clientListRequest = $.ajax({
		url : '/bwf/topology/client/'
		,type : 'GET'
		,dataType : 'json'
	});
	clientListRequest.done(function(clientList) {
		clientMap.clear();

		for ( var i = 0; i < clientList.length; i++ ) {
			oneClientData = clientList[i];
			topologyTree.insertNewChild(
					0
					,oneClientData['clientCode']
					,oneClientData['clientName']);

			clientMap.put(oneClientData['clientCode'], oneClientData);
		}

		initProject();
		initMenu();
		// default root id : 0
		setDataView(0);
	});
	clientListRequest.fail(function(jqXHR, textStatus) {
		alert('Request failed!');
	});
}

function initProject() {
	var projectListRequest = $.ajax({
		url : '/bwf/topology/project/'
		,type : 'GET'
		,dataType : 'json'
	});
	projectListRequest.done(function(projectList) {
		projectMap.clear();
		subMenuMap.clear();

		for ( var i = 0; i < projectList.length; i++ ) {
			oneProjectData 	= projectList[i];
			clientCode 		= oneProjectData['clientCode'];
			projectCode		= oneProjectData['clientCode'] + '-' + oneProjectData['projectCode'];

			topologyTree.insertNewChild(
					clientCode
					,projectCode
					,oneProjectData['projectName']);

			topologyTree.insertNewChild(projectCode, projectCode + '-1', '설계문서');
			topologyTree.insertNewChild(projectCode, projectCode + '-2', '회의록');
			topologyTree.insertNewChild(projectCode, projectCode + '-3', '게시판');
			topologyTree.insertNewChild(projectCode, projectCode + '-4', 'PRETI');

			projectMap.put(projectCode, oneProjectData);
		}

		// default root id : 0
		topologyTree.closeAllItems(0);

		subMenuMap.put(1, '설계문서');
		subMenuMap.put(2, '회의록');
		subMenuMap.put(3, '게시판');
		subMenuMap.put(4, 'PRETI');
	});
	projectListRequest.fail(function(jqXHR, textStatus) {
		alert('Request failed!');
	});
}

function initMenu() {
	topologyTreeMenu = new dhtmlXMenuObject();

//	topologyTreeMenu.setIconsPath(IMAGE_PATH + '/dhxmenu_web/');
//	topologyTreeMenu.setSkin('dhx_web');
	topologyTreeMenu.renderAsContextMenu();

	//addNewChild(parentId, pos, itemId, itemText, disabled, imgEnabled, imgDisabled)
	topologyTreeMenu.addNewChild(null, 0, INSERT_CLIENT, '고객사 등록');
	topologyTreeMenu.addNewChild(null, 1, UPDATE_CLIENT, '고객사 변경');
	topologyTreeMenu.addNewChild(null, 2, DELETE_CLIENT, '고객사 삭제');
	topologyTreeMenu.addNewChild(null, 3, INSERT_PROJECT, '프로젝트 등록');
	topologyTreeMenu.addNewChild(null, 4, UPDATE_PROJECT, '프로젝트 변경');
	topologyTreeMenu.addNewChild(null, 5, DELETE_PROJECT, '프로젝트 삭제');

	topologyTreeMenu.addNewSeparator(DELETE_CLIENT);

	topologyTreeMenu.attachEvent('onClick', function(menuItemId, type) {
		switch ( menuItemId ) {
		case INSERT_CLIENT :
			insertClient();
			break;
		case UPDATE_CLIENT :
			updateClient();
			break;
		case DELETE_CLIENT :
			deleteClient();
			break;
		case INSERT_PROJECT :
			insertProject();
			break;
		case UPDATE_PROJECT :
			updateProject();
			break;
		case DELETE_PROJECT :
			deleteProject();
			break;
		}
	});

	topologyTreeMenu.addContextZone('treeDiv');
	$('#treeDiv').on('contextmenu', function() {
		topologyTreeMenu.setItemEnabled(INSERT_CLIENT);
		topologyTreeMenu.setItemDisabled(UPDATE_CLIENT);
		topologyTreeMenu.setItemDisabled(DELETE_CLIENT);
		topologyTreeMenu.setItemDisabled(INSERT_PROJECT);
		topologyTreeMenu.setItemDisabled(UPDATE_PROJECT);
		topologyTreeMenu.setItemDisabled(DELETE_PROJECT);

		topologyTree.clearSelection();
	});

	topologyTree.enableContextMenu(topologyTreeMenu);
	topologyTree.attachEvent('onBeforeContextMenu', showTopologyTreeMenu);
}

function showTopologyTreeMenu(itemId) {
	oneClientData = clientMap.get(itemId);

	if ( oneClientData != null ) {
		topologyTreeMenu.setItemDisabled(INSERT_CLIENT);
		topologyTreeMenu.setItemEnabled(UPDATE_CLIENT);
		topologyTreeMenu.setItemEnabled(DELETE_CLIENT);
		topologyTreeMenu.setItemEnabled(INSERT_PROJECT);
		topologyTreeMenu.setItemDisabled(UPDATE_PROJECT);
		topologyTreeMenu.setItemDisabled(DELETE_PROJECT);
	}
	else {
		oneProjectData = projectMap.get(itemId);

		if ( oneProjectData != null ) {
			topologyTreeMenu.setItemDisabled(INSERT_CLIENT);
			topologyTreeMenu.setItemDisabled(UPDATE_CLIENT);
			topologyTreeMenu.setItemDisabled(DELETE_CLIENT);
			topologyTreeMenu.setItemDisabled(INSERT_PROJECT);
			topologyTreeMenu.setItemEnabled(UPDATE_PROJECT);
			topologyTreeMenu.setItemEnabled(DELETE_PROJECT);
		}
		else {
			return false;
		}
	}

	return true;
}

function insertClient() {
	var dhxWins				= new dhtmlXWindows();
	var insertClientWindow 	= dhxWins.createWindow({
		id : 'insertClientWindow'
		,left : 100
		,top : 100
		,width : 270
		,height : 160
		,center : true
	});

	insertClientWindow.setText('고객사 등록');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('insertClientWindow').setModal(true);

	var insertClientFormData = [
	                            {type : 'settings', position : 'label-left', labelWidth : 80, inputWidth : 'auto'}
	                            ,{type : 'input', name : 'input_ClientName', label : '고객사명'}
	                            ,{type : 'input', name : 'input_ClientCode', label : '고객사 코드'}
	                            ,{type : 'block', blockOffset : 0, offsetTop : 5, offsetLeft : 95
	                            	,list: [
	                            	        {type : 'button', name : 'insertButton', value : '등록'}
	                            	        ,{type : 'newcolumn'}
	                            	        ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	        ]}
	                            ];

	var insertClientForm = insertClientWindow.attachForm(insertClientFormData);

	insertClientForm.setSkin('dhx_web');
	insertClientForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'insertButton') {
			var clientName 	= insertClientForm.getItemValue('input_ClientName');
			var clientCode 	= insertClientForm.getItemValue('input_ClientCode');

			if ( clientName != '' && clientCode != '' ) {
				var json = $.toJSON({
					'clientCode' : clientCode
					,'clientName' : clientName});

				var insertRequest = $.ajax({
					url : '/bwf/topology/insertClient'
					,type : 'POST'
					,contentType : 'application/json; charset=UTF-8'
					,data : json
					,dataType : 'json'
				});
				insertRequest.done(function(data) {
					if ( data['result'] == 'OK' ) {
						dhxWins.window('insertClientWindow').close();
						initTree();
					}
					else {
						alert(data['reason']);

						if ( data['result'] == 'CLIENT_CODE_EXIST' ) {
							insertClientForm.setItemFocus('input_ClientCode');
						}
						else if ( data['result'] == 'CLIENT_NAME_EXIST' || 
								data['result'] == 'CLIENT_INFO_EXIST' ) {
							insertClientForm.setItemFocus('input_ClientName');
						}
					}
				});
				insertRequest.fail(function(jqXHR, textStatus) {
					alert('Request failed: ' + textStatus);
				});
			}
			else if ( clientName == '' ) {
				if ( clientCode == '' ) {
					alert('고객사명, 고객사 코드를 입력하세요.');
				}
				else {
					alert('고객사명을 입력하세요.');
				}

				insertClientForm.setItemFocus('input_ClientName');
			}
			else if ( clientCode == '' ) {
				alert('고객사 코드를 입력하세요.');
				insertClientForm.setItemFocus('input_ClientCode');
			}
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('insertClientWindow').close();
		}
	});
	insertClientForm.attachEvent('onKeyUp', function(inp, ev, name, value) {
		if ( name == 'input_ClientCode' ) {
			var inputValue 	= insertClientForm.getItemValue('input_ClientCode');
			var numRegx 	= /[^0-9]/gi;
			var numValue 	= inputValue.replace(numRegx, '');

			insertClientForm.setItemValue('input_ClientCode', numValue);
		}
	});
}

function updateClient() {
	var clientCode			= topologyTree.getSelectedItemId();
	var dhxWins				= new dhtmlXWindows();
	var updateClientWindow 	= dhxWins.createWindow({
		id : 'updateClientWindow'
		,left : 100
		,top : 100
		,width : 270
		,height : 160
		,center : true
	});
	
	var oneClientData 		= clientMap.get(clientCode);

	updateClientWindow.setText('고객사 변경');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('updateClientWindow').setModal(true);

	var updateClientFormData = [
	                            {type : 'settings', position : 'label-left', labelWidth : 80, inputWidth : 'auto'}
	                            ,{type : 'input', name : 'input_ClientName', label : '고객사명', value : oneClientData['clientName']}
	                            ,{type : 'input', name : 'input_ClientCode', label : '고객사 코드', value : oneClientData['clientCode']}
	                            ,{type : 'block', blockOffset : 0, offsetTop : 5, offsetLeft : 95
	                            	,list: [
	                            	        {type : 'button', name : 'updateButton', value : '변경'}
	                            	        ,{type : 'newcolumn'}
	                            	        ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	        ]}
	                            ];

	var updateClientForm = updateClientWindow.attachForm(updateClientFormData);

	updateClientForm.setSkin('dhx_web');
	updateClientForm.disableItem('input_ClientCode');
	updateClientForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'updateButton') {
			var clientName 	= updateClientForm.getItemValue('input_ClientName');
			var clientCode	= updateClientForm.getItemValue('input_ClientCode');

			if ( clientName != '' ) {
				var json = $.toJSON({
					'clientName' : clientName
					,'clientCode' : clientCode});

				var updateRequest = $.ajax({
					url : '/bwf/topology/updateClient'
					,type : 'PUT'
					,contentType : 'application/json; charset=UTF-8'
					,data : json
					,dataType : 'json'
				});
				updateRequest.done(function(data) {
					if ( data['result'] == 'OK' ) {
						dhxWins.window('updateClientWindow').close();
						initTree();
					}
					else {
						alert(data['reason']);

						if ( data['result'] == 'CLIENT_NAME_EXIST' ) {
							updateClientForm.setItemFocus('input_ClientName');
						}
					}
				});
				updateRequest.fail(function(jqXHR, textStatus) {
					alert('Request failed: ' + textStatus);
				});
			}
			else {
				alert('고객사명을 입력하세요.');
				updateClientForm.setItemFocus('input_ClientName');
			}
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('updateClientWindow').close();
		}
	});
}

function deleteClient() {
	var clientCode 			= topologyTree.getSelectedItemId();
	var oneClientData		= clientMap.get(clientCode);
	var dhxWins				= new dhtmlXWindows();
	var deleteClientWindow 	= dhxWins.createWindow({
		id : 'deleteClientWindow'
		,left :100
		,top : 100
		,width : 300
		,height : 150
		,center : true
	});

	deleteClientWindow.setText('고객사 삭제');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('deleteClientWindow').setModal(true);

	var deleteClientFormData = [
	                            {type : 'settings', position : 'label-left', labelWidth : 'auto'}
	                            ,{type : 'label', label : oneClientData['clientName'] + ' 고객사를 삭제 하시겠습니까?'}
	                            ,{type : 'block', blockOffset : 0, offsetTop : 20, offsetLeft : 80
	                            	,list: [
	                            	        {type : 'button', name : 'deleteButton', value : '삭제'}
	                            	        ,{type : 'newcolumn'}
	                            	        ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	        ]}
	                            ];

	var deleteClientForm = deleteClientWindow.attachForm(deleteClientFormData);

	deleteClientForm.setSkin('dhx_web');
	deleteClientForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'deleteButton') {
			var json 			= $.toJSON({'clientCode' : clientCode});
			var deleteRequest 	= $.ajax({
				url : '/bwf/topology/deleteClient/' + clientCode
				,type : 'DELETE'
				,contentType : 'application/json; charset=UTF-8'
				,data : json
				,dataType : 'json'
			});
			deleteRequest.done(function(data) {
				dhxWins.window('deleteClientWindow').close();
				initTree();
			});
			deleteRequest.fail(function(jqXHR, textStatus) {
				alert('Request failed: ' + textStatus);
			});
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('deleteClientWindow').close();
		}
	});
}

function insertProject() {
	var clientCode 			= topologyTree.getSelectedItemId();
	var dhxWins				= new dhtmlXWindows();
	var insertProjectWindow = dhxWins.createWindow({
		id : 'insertProjectWindow'
		,left : 100
		,top : 100
		,width : 270
		,height : 180
		,center : true
	});
	var oneClientData		= clientMap.get(clientCode);

	insertProjectWindow.setText('프로젝트 등록');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('insertProjectWindow').setModal(true);

	var insertProjectFormData = [
	                             {type : 'settings', position : 'label-left', labelWidth : 80, inputWidth : 'auto'}
	                             ,{type : 'input', name : 'input_ClientName', label : '고객사명', value : oneClientData['clientName']}
	                             ,{type : 'input', name : 'input_ProjectName', label : '프로젝트명'}
	                             ,{type : 'input', name : 'input_ProjectCode', label : '프로젝트 코드'}
	                             ,{type : 'block', blockOffset : 0, offsetLeft : 95
	                            	 ,list: [
	                            	         {type : 'button', name : 'insertButton', value : '등록'}
	                            	         ,{type : 'newcolumn'}
	                            	         ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	         ]}
	                             ];

	var insertProjectForm = insertProjectWindow.attachForm(insertProjectFormData);

	insertProjectForm.setSkin('dhx_web');
	insertProjectForm.disableItem('input_ClientName');
	insertProjectForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'insertButton') {
			var projectName = insertProjectForm.getItemValue('input_ProjectName');
			var projectCode = insertProjectForm.getItemValue('input_ProjectCode');

			if ( projectName != '' && projectCode != '' ) {
				var json 			= $.toJSON({
					'clientCode' : clientCode
					,'projectCode' : projectCode
					,'projectName' : projectName});

				var insertRequest 	= $.ajax({
					url : '/bwf/topology/insertProject'
					,type : 'POST'
					,contentType : 'application/json; charset=UTF-8'
					,data : json
					,dataType : 'json'
				});
				insertRequest.done(function(data) {
					if ( data['result'] == 'OK' ) {
						dhxWins.window('insertProjectWindow').close();
						initTree();
					}
					else {
						alert(data['reason']);

						if ( data['result'] == 'PROJECT_CODE_EXIST' ) {
							insertProjectForm.setItemFocus('input_ProjectCode');
						}
						else if ( data['result'] == 'PROJECT_NAME_EXIST' || 
								data['result'] == 'PROJECT_INFO_EXIST' ) {
							insertProjectForm.setItemFocus('input_ProjectName');
						}
					}
				});
				insertRequest.fail(function(jqXHR, textStatus) {
					alert('Request failed: ' + textStatus);
				});
			}
			else if ( projectName == '' ) {
				if ( projectCode == '' ) {
					alert('프로젝트명, 프로젝트 코드를 입력하세요.');
				}
				else {
					alert('프로젝트명을 입력하세요.');
				}

				insertProjectForm.setItemFocus('input_ProjectName');
			}
			else if ( projectCode == '' ) {
				alert('프로젝트 코드를 입력하세요.');
				insertProjectForm.setItemFocus('input_ProjectCode');
			}
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('insertProjectWindow').close();
		}
	});
	insertProjectForm.attachEvent('onKeyUp', function(inp, ev, name, value) {
		if ( name == 'input_ProjectCode' ) {
			var inputValue 	= insertProjectForm.getItemValue('input_ProjectCode');
			var numRegx 	= /[^0-9]/gi;
			var numValue 	= inputValue.replace(numRegx, '');

			insertProjectForm.setItemValue('input_ProjectCode', numValue);
		}
	});
}

function updateProject() {
	var itemId		= topologyTree.getSelectedItemId();
	var itemIdArray	= itemId.split('-');
	var clientCode;

	if ( itemIdArray.length == 2 ) {
		clientCode = itemIdArray[0];
	}
	else {
		return;
	}

	var dhxWins				= new dhtmlXWindows();
	var updateProjectWindow = dhxWins.createWindow({
		id : 'updateProjectWindow'
		,left : 100
		,top : 100
		,width : 270
		,height : 180
		,center : true
	});
	var oneClientData 		= clientMap.get(clientCode);
	var oneProjectData		= projectMap.get(itemId);

	updateProjectWindow.setText('프로젝트 변경');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('updateProjectWindow').setModal(true);

	var updateProjectFormData = [
	                             {type : 'settings', position : 'label-left', labelWidth : 80, inputWidth : 'auto'}
	                             ,{type : 'input', name : 'input_ClientName', label : '고객사명', value : oneClientData['clientName']}
	                             ,{type : 'input', name : 'input_ProjectName', label : '프로젝트명', value : oneProjectData['projectName']}
	                             ,{type : 'input', name : 'input_ProjectCode', label : '프로젝트 코드', value : oneProjectData['projectCode']}
	                             ,{type : 'block', blockOffset : 0, offsetTop : 5, offsetLeft : 95
	                            	 ,list: [
	                            	         {type : 'button', name : 'updateButton', value : '변경'}
	                            	         ,{type : 'newcolumn'}
	                            	         ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	         ]}
	                             ];

	var updateProjectForm = updateProjectWindow.attachForm(updateProjectFormData);

	updateProjectForm.setSkin('dhx_web');
	updateProjectForm.disableItem('input_ClientName');
	updateProjectForm.disableItem('input_ProjectCode');
	updateProjectForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'updateButton') {
			var projectName = updateProjectForm.getItemValue('input_ProjectName');
			var projectCode	= updateProjectForm.getItemValue('input_ProjectCode');

			if ( projectName != '' ) {
				var json = $.toJSON({
					'clientCode' : oneClientData['clientCode']
					,'projectName' : projectName
					,'projectCode' : projectCode});

				var updateRequest = $.ajax({
					url : '/bwf/topology/updateProject'
					,type : 'PUT'
					,contentType : 'application/json; charset=UTF-8'
					,data : json
					,dataType : 'json'
				});
				updateRequest.done(function(data) {
					if ( data['result'] == 'OK' ) {
						dhxWins.window('updateProjectWindow').close();
						initTree();
					}
					else {
						alert(data['reason']);

						if ( data['result'] == 'PROJECT_NAME_EXIST' ) {
							updateProjectForm.setItemFocus('input_ProjectName');
						}
					}
				});
				updateRequest.fail(function(jqXHR, textStatus) {
					alert('Request failed: ' + textStatus);
				});
			}
			else {
				alert('프로젝트명을 입력하세요.');
				updateProjectForm.setItemFocus('input_ProjectName');
			}
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('updateProjectWindow').close();
		}
	});
}

function deleteProject() {
	var itemId		= topologyTree.getSelectedItemId();
	var itemIdArray	= itemId.split('-');
	var clientCode;
	var projectCode;

	if ( itemIdArray.length == 2 ) {
		clientCode 	= itemIdArray[0];
		projectCode = itemIdArray[1];
	}
	else {
		return;
	}

	var oneClientData		= clientMap.get(clientCode);
	var oneProjectData		= projectMap.get(itemId);
	var dhxWins				= new dhtmlXWindows();
	var deleteProjectWindow = dhxWins.createWindow({
		id : 'deleteProjectWindow'
		,left : 100
		,top : 100
		,width : 300
		,height : 150
		,center : true
	});

	deleteProjectWindow.setText('프로젝트 삭제');
	//dhxWins.setSkin('dhx_web');
	dhxWins.window('deleteProjectWindow').setModal(true);

	var deleteProjectFormData = [
	                             {type : 'settings', position : 'label-left', labelWidth : 'auto'}
	                             ,{type : 'label', label : oneClientData['clientName'] + ' / ' + oneProjectData['projectName'] + ' 프로젝트를 삭제 하시겠습니까?'}
	                             ,{type : 'block', blockOffset : 0, offsetTop : 20, offsetLeft : 80
	                            	 ,list: [
	                            	         {type : 'button', name : 'deleteButton', value : '삭제'}
	                            	         ,{type : 'newcolumn'}
	                            	         ,{type : 'button', name : 'cancleButton', value : '취소'}
	                            	         ]}
	                             ];

	var deleteProjectForm = deleteProjectWindow.attachForm(deleteProjectFormData);

	deleteProjectForm.setSkin('dhx_web');
	deleteProjectForm.attachEvent('onButtonClick', function(name) {
		if ( name == 'deleteButton') {
			var json = $.toJSON({
				'clientCode' : clientCode
				,'projectCode' : projectCode
				,'projectName' : oneProjectData['projectName']
			});
			var deleteRequest 	= $.ajax({
				url : '/bwf/topology/deleteProject'
				,type : 'DELETE'
				,contentType : 'application/json; charset=UTF-8'
				,data : json
				,dataType : 'json'
			});
			deleteRequest.done(function(data) {
				dhxWins.window('deleteProjectWindow').close();
				initTree();
			});
			deleteRequest.fail(function(jqXHR, textStatus) {
				alert('Request failed: ' + textStatus);
			});
		}
		else if ( name == 'cancleButton' ) {
			dhxWins.window('deleteProjectWindow').close();
		}
	});
}

function setTitleAndCallBoard(id) {
	var idArray 	= String(id).split('-');
	var boardTitle 	= '';

	var oneClientData;
	var oneProjectData;
	var subMenuItemCode;

	switch ( idArray.length ) {
	case 1 :
		oneClientData 	= clientMap.get(idArray[0]);
		boardTitle		= oneClientData['clientName'];
		
		boardLayout.setText(boardTitle);
		break;
	case 2 :
		oneClientData	= clientMap.get(idArray[0]);
		oneProjectData 	= projectMap.get(idArray[0] + '-' + idArray[1]);
		boardTitle		= oneClientData['clientName'] + ' / ' + oneProjectData['projectName'];
		
		boardLayout.setText(boardTitle);
		break;
	case 3 :
		oneClientData	= clientMap.get(idArray[0]);
		oneProjectData 	= projectMap.get(idArray[0] + '-' + idArray[1]);
		subMenuItemCode	= subMenuMap.get(idArray[2]);
		//boardTitle		= oneClientData['clientName'] + ' / ' + oneProjectData['projectName'] + ' / ' + subMenuItemCode;

		initTable(oneClientData, oneProjectData, subMenuItemCode);
		break;
	}
}

function setDataView(id) {
	var subItemList = topologyTree.getSubItems(id);

	if ( subItemList.length != 0 ) {
		initDataView(subItemList);
	}
}